package dao;

import java.util.List;

import modelo.Auditoria;
import modelo.Contato;

import org.hibernate.Criteria;
import org.hibernate.Session;

public class AuditoriaDAO {public static final long UNSAVED_ID = 0;



public AuditoriaDAO() throws Exception{
}


public void persiste(Auditoria auditoria, Session session) throws Exception{
	if(auditoria.getId()==UNSAVED_ID)
		adiciona(auditoria, session);
	else
		atualiza(auditoria, session);
}

public void adiciona(Auditoria auditoria, Session session) throws Exception{
	session.save(auditoria);
}

public void remove(Auditoria auditoria, Session session) throws Exception{
	session.delete(auditoria);
}

public void atualiza(Auditoria auditoria, Session session) throws Exception{
	session.update(auditoria);
}

public Auditoria obtem(long id, Session session) throws Exception{
	return (Auditoria) session.load(Auditoria.class, id);
}

public List<Auditoria> listar(String filtro, Session session) throws Exception{
	Criteria crit = session.createCriteria(Auditoria.class);
//	crit.add(Restrictions.like("nome", "M", MatchMode.EXACT));
//	crit.addOrder(Order.desc("nome"));
	return crit.list();
	
	
	
}
}